﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using InkFx.WinControl.Core;

namespace InkFx.WinControl
{
    [ToolboxItem(false), Docking(DockingBehavior.Never), Designer(typeof(SimpPanelDesigner))]
    public class SimpPanel : System.Windows.Forms.Panel
    {
        public SimpPanel()
        {
            SetStyle(Win32API.ControlStylesUAORSD, true);

            //base.BackColor = Color.Transparent;
        }

        #region  注 销 属 性

        public override Color BackColor
        {
            get { return base.BackColor; }
            set { base.BackColor = value; }
        }

        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new bool AutoScroll
        {
            get { return base.AutoScroll; }
            set { base.AutoScroll = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new Size AutoScrollMargin
        {
            get { return base.AutoScrollMargin; }
            set { base.AutoScrollMargin = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new Size AutoScrollMinSize
        {
            get { return base.AutoScrollMinSize; }
            set { base.AutoScrollMinSize = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new bool AllowDrop
        {
            get { return base.AllowDrop; }
            set { base.AllowDrop = value; }
        }

        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new string AccessibleName
        {
            get { return base.AccessibleName; }
            set { base.AccessibleName = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new string AccessibleDescription
        {
            get { return base.AccessibleDescription; }
            set { base.AccessibleDescription = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new AccessibleRole AccessibleRole
        {
            get { return base.AccessibleRole; }
            set { base.AccessibleRole = value; }
        }

        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new ControlBindingsCollection DataBindings
        {
            get { return base.DataBindings; }
        }

        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new System.Windows.Forms.ContextMenuStrip ContextMenuStrip
        {
            get { return base.ContextMenuStrip; }
            set { base.ContextMenuStrip = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new bool Enabled
        {
            get { return base.Enabled; }
            set { base.Enabled = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new ImeMode ImeMode
        {
            get { return base.ImeMode; }
            set { base.ImeMode = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new bool CausesValidation
        {
            get { return base.CausesValidation; }
            set { base.CausesValidation = value; }
        }

        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new bool AutoSize
        {
            get { return base.AutoSize; }
            set { base.AutoSize = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new AutoSizeMode AutoSizeMode
        {
            get { return base.AutoSizeMode; }
            set { base.AutoSizeMode = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new AnchorStyles Anchor
        {
            get { return base.Anchor; }
            set { base.Anchor = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new BorderStyle BorderStyle
        {
            get { return base.BorderStyle; }
            set { base.BorderStyle = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new DockStyle Dock
        {
            get { return base.Dock; }
            set { base.Dock = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new ScrollableControl.DockPaddingEdges DockPadding
        {
            get { return base.DockPadding; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new int Height
        {
            get { return base.Height; }
            set { base.Height = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new Point Location
        {
            get { return base.Location; }
            set { base.Location = value; }
        }
        protected override Padding DefaultMargin
        {
            get { return new Padding(0, 0, 0, 0); }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new Size MinimumSize
        {
            get { return base.MinimumSize; }
            set { base.MinimumSize = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new Size MaximumSize
        {
            get { return base.MaximumSize; }
            set { base.MaximumSize = value; }
        }

        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new Padding Margin
        {
            get { return base.Margin; }
            set { base.Margin = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new Padding Padding
        {
            get { return base.Padding; }
            set { base.Padding = value; }
        }

        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new string Name
        {
            get { return base.Name; }
            set { base.Name = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new System.Windows.Forms.Control Parent
        {
            get { return base.Parent; }
            set { base.Parent = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new Size Size
        {
            get { return base.Size; }
            set { base.Size = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new int TabIndex
        {
            get { return base.TabIndex; }
            set { base.TabIndex = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new bool TabStop
        {
            get { return base.TabStop; }
            set { base.TabStop = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new bool Visible
        {
            get { return base.Visible; }
            set { base.Visible = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new int Width
        {
            get { return base.Width; }
            set { base.Width = value; }
        }

        #endregion


        #region  注 销 事 件

        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler AutoSizeChanged
        {
            add { base.AutoSizeChanged += value; }
            remove { base.AutoSizeChanged -= value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler VisibleChanged
        {
            add { base.VisibleChanged += value; }
            remove { base.VisibleChanged -= value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler DockChanged
        {
            add { base.DockChanged += value; }
            remove { base.DockChanged -= value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler LocationChanged
        {
            add { base.LocationChanged += value; }
            remove { base.LocationChanged -= value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler TabIndexChanged
        {
            add { base.TabIndexChanged += value; }
            remove { base.TabIndexChanged -= value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler TabStopChanged
        {
            add { base.TabStopChanged += value; }
            remove { base.TabStopChanged -= value; }
        }


        #endregion
    }

    public class SimpPanelDesigner : ScrollableControlDesigner
    {
        private SimpPanelActionList actionList;
        public override DesignerActionListCollection ActionLists
        {
            get
            {
                if (actionList == null)
                    actionList = new SimpPanelActionList(this.Component);

                DesignerActionListCollection listAction = new DesignerActionListCollection(); //base.ActionLists;
                if (!listAction.Contains(actionList))
                    listAction.Add(actionList);
                return listAction;
            }
        }
        public override SelectionRules SelectionRules
        {
            get
            {
                //return SelectionRules.Locked;
                //SelectionRules selectionRules = base.SelectionRules;
                ////object component = base.Component;
                //selectionRules &= ~(SelectionRules.AllSizeable);
                //return selectionRules;

                SelectionRules result = SelectionRules.None;
                //System.Windows.Forms.Control control = this.Control;
                //if (control.Parent is SimpPanel)
                //{
                //    result = SelectionRules.Locked;
                //}
                return result;
            }
        }

        public class SimpPanelActionList : DesignerActionList
        {
            private SimpPanel control;
            public SimpPanelActionList(IComponent component) : base(component)
            {
                this.control = component as SimpPanel;
            }

            public override DesignerActionItemCollection GetSortedActionItems()
            {
                DesignerActionItemCollection items = new DesignerActionItemCollection();
                //items.Add(new DesignerActionMethodTagItem(this, "Select", "全部隐藏", "NULL"));
                return items;
            }

            public void Select(object tag)
            {
                ////MessageBox.ShowInfo("Select: " + tag);

                //if (tag + "" == "NULL")
                //    control.Select(null);
                //else
                //{
                //    System.Windows.Forms.Control ctrl = tag as System.Windows.Forms.Control;
                //    if (control == null || control.Disposing || control.IsDisposed) return;
                //    if (ctrl == null || !control.Contains(ctrl)) return;
                //    control.Select(ctrl);
                //}

                //CreateCode();
            }

            private void CreateCode()
            {
                ////var designerHost = (IDesignerHost)this.Component.Site.GetService(typeof(IDesignerHost));
                ////var designer = (MultiPanelDesigner)designerHost.GetDesigner(this.control);

                //PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(this.Component)["SelectedControl"];
                //if (propertyDescriptor != null && this.control != null)
                //    propertyDescriptor.SetValue(this.Component, this.control.SelectedControl);
            }
        }

    }

    //internal class SimpPanelDesigner : ScrollableControlDesigner
    //{
    //    private IDesignerHost designerHost;
    //    //private SplitContainerDesigner splitContainerDesigner;
    //    private SimpPanel splitterPanel;
    //    private bool selected;
    //    protected override InheritanceAttribute InheritanceAttribute
    //    {
    //        get
    //        {
    //            if (this.splitterPanel != null && this.splitterPanel.Parent != null)
    //            {
    //                return (InheritanceAttribute)TypeDescriptor.GetAttributes(this.splitterPanel.Parent)[typeof(InheritanceAttribute)];
    //            }
    //            return base.InheritanceAttribute;
    //        }
    //    }
    //    internal bool Selected
    //    {
    //        get
    //        {
    //            return this.selected;
    //        }
    //        set
    //        {
    //            this.selected = value;
    //            if (this.selected)
    //            {
    //                this.DrawSelectedBorder();
    //                return;
    //            }
    //            this.EraseBorder();
    //        }
    //    }
    //    public override IList SnapLines
    //    {
    //        get
    //        {
    //            ArrayList result = null;
    //            base.AddPaddingSnapLines(ref result);
    //            return result;
    //        }
    //    }
    //    public override SelectionRules SelectionRules
    //    {
    //        get
    //        {
    //            //SelectionRules selectionRules = base.SelectionRules;
    //            ////object component = base.Component;
    //            //selectionRules &= ~(SelectionRules.AllSizeable);
    //            //return selectionRules;

    //            SelectionRules result = SelectionRules.None;
    //            System.Windows.Forms.Control control = this.Control;
    //            if (control.Parent is SimpPanel)
    //            {
    //                result = SelectionRules.Locked;
    //            }
    //            return result;
    //        }
    //    }
    //    public override bool CanBeParentedTo(IDesigner parentDesigner)
    //    {
    //        return false; //parentDesigner is SplitContainerDesigner;
    //    }
    //    protected override void OnDragEnter(DragEventArgs de)
    //    {
    //        if (this.InheritanceAttribute == InheritanceAttribute.InheritedReadOnly)
    //        {
    //            de.Effect = DragDropEffects.None;
    //            return;
    //        }
    //        base.OnDragEnter(de);
    //    }
    //    protected override void OnDragOver(DragEventArgs de)
    //    {
    //        if (this.InheritanceAttribute == InheritanceAttribute.InheritedReadOnly)
    //        {
    //            de.Effect = DragDropEffects.None;
    //            return;
    //        }
    //        base.OnDragOver(de);
    //    }
    //    protected override void OnDragLeave(EventArgs e)
    //    {
    //        if (this.InheritanceAttribute == InheritanceAttribute.InheritedReadOnly)
    //        {
    //            return;
    //        }
    //        base.OnDragLeave(e);
    //    }
    //    protected override void OnDragDrop(DragEventArgs de)
    //    {
    //        if (this.InheritanceAttribute == InheritanceAttribute.InheritedReadOnly)
    //        {
    //            de.Effect = DragDropEffects.None;
    //            return;
    //        }
    //        base.OnDragDrop(de);
    //    }
    //    protected override void OnMouseHover()
    //    {
    //        //if (this.splitContainerDesigner != null)
    //        //{
    //        //    this.splitContainerDesigner.SplitterPanelHover();
    //        //}
    //    }
    //    protected override void Dispose(bool disposing)
    //    {
    //        IComponentChangeService componentChangeService = (IComponentChangeService)this.GetService(typeof(IComponentChangeService));
    //        if (componentChangeService != null)
    //        {
    //            componentChangeService.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
    //        }
    //        base.Dispose(disposing);
    //    }
    //    public override void Initialize(IComponent component)
    //    {
    //        base.Initialize(component);
    //        this.splitterPanel = (SimpPanel)component;
    //        this.designerHost = (IDesignerHost)component.Site.GetService(typeof(IDesignerHost));
    //        //this.splitContainerDesigner = (SplitContainerDesigner)this.designerHost.GetDesigner(this.splitterPanel.Parent);
    //        IComponentChangeService componentChangeService = (IComponentChangeService)this.GetService(typeof(IComponentChangeService));
    //        if (componentChangeService != null)
    //        {
    //            componentChangeService.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
    //        }
    //        PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(component)["Locked"];
    //        if (propertyDescriptor != null && this.splitterPanel.Parent is SimpPanel)
    //        {
    //            propertyDescriptor.SetValue(component, true);
    //        }
    //    }
    //    private void OnComponentChanged(object sender, ComponentChangedEventArgs e)
    //    {
    //        if (this.splitterPanel.Parent == null)
    //        {
    //            return;
    //        }
    //        if (this.splitterPanel.Controls.Count == 0)
    //        {
    //            Graphics graphics = this.splitterPanel.CreateGraphics();
    //            this.DrawWaterMark(graphics);
    //            graphics.Dispose();
    //            return;
    //        }
    //        this.splitterPanel.Invalidate();
    //    }
    //    internal void DrawSelectedBorder()
    //    {
    //        System.Windows.Forms.Control control = this.Control;
    //        Rectangle clientRectangle = control.ClientRectangle;
    //        using (Graphics graphics = control.CreateGraphics())
    //        {
    //            Color color;
    //            if ((double)control.BackColor.GetBrightness() < 0.5)
    //            {
    //                color = ControlPaint.Light(control.BackColor);
    //            }
    //            else
    //            {
    //                color = ControlPaint.Dark(control.BackColor);
    //            }
    //            using (Pen pen = new Pen(color))
    //            {
    //                pen.DashStyle = DashStyle.Dash;
    //                clientRectangle.Inflate(-4, -4);
    //                graphics.DrawRectangle(pen, clientRectangle);
    //            }
    //        }
    //    }
    //    internal void EraseBorder()
    //    {
    //        System.Windows.Forms.Control control = this.Control;
    //        Rectangle clientRectangle = control.ClientRectangle;
    //        Graphics graphics = control.CreateGraphics();
    //        Color backColor = control.BackColor;
    //        Pen pen = new Pen(backColor);
    //        pen.DashStyle = DashStyle.Dash;
    //        clientRectangle.Inflate(-4, -4);
    //        graphics.DrawRectangle(pen, clientRectangle);
    //        pen.Dispose();
    //        graphics.Dispose();
    //        control.Invalidate();
    //    }
    //    internal void DrawWaterMark(Graphics g)
    //    {
    //        System.Windows.Forms.Control control = this.Control;
    //        Rectangle clientRectangle = control.ClientRectangle;
    //        string name = control.Name;
    //        using (Font font = new Font("Arial", 8f))
    //        {
    //            int x = clientRectangle.Width / 2 - (int)g.MeasureString(name, font).Width / 2;
    //            int y = clientRectangle.Height / 2;
    //            Color foreColor = Color.Black;
    //            IUIService iUIService = this.GetService(typeof(IUIService)) as IUIService;
    //            if (iUIService != null && iUIService.Styles["SmartTagText"] is Color)
    //            {
    //                foreColor = (Color)iUIService.Styles["SmartTagText"];
    //            }
    //            TextRenderer.DrawText(g, name, font, new Point(x, y), foreColor, TextFormatFlags.Default);
    //        }
    //    }
    //    protected override void OnPaintAdornments(PaintEventArgs pe)
    //    {
    //        base.OnPaintAdornments(pe);
    //        if (this.splitterPanel.BorderStyle == BorderStyle.None)
    //        {
    //            //this.DrawBorder(pe.Graphics);
    //        }
    //        if (this.Selected)
    //        {
    //            this.DrawSelectedBorder();
    //        }
    //        if (this.splitterPanel.Controls.Count == 0)
    //        {
    //            this.DrawWaterMark(pe.Graphics);
    //        }
    //    }
    //    protected override void PreFilterProperties(IDictionary properties)
    //    {
    //        base.PreFilterProperties(properties);
    //        properties.Remove("Modifiers");
    //        properties.Remove("Locked");
    //        properties.Remove("GenerateMember");
    //        foreach (DictionaryEntry dictionaryEntry in properties)
    //        {
    //            PropertyDescriptor propertyDescriptor = (PropertyDescriptor)dictionaryEntry.Value;
    //            if (propertyDescriptor.Name.Equals("Name") && propertyDescriptor.DesignTimeOnly)
    //            {
    //                properties[dictionaryEntry.Key] = TypeDescriptor.CreateProperty(propertyDescriptor.ComponentType, propertyDescriptor, new Attribute[]
    //                {
    //                    BrowsableAttribute.No,
    //                    DesignerSerializationVisibilityAttribute.Hidden
    //                });
    //                break;
    //            }
    //        }
    //    }
    //}


    //public class SimpPanelDesigner : ParentControlDesigner
    //{
    //    public class TestControlDesignerActionList : DesignerActionList
    //    {
    //        private SimpPanelDesigner m_Desinger;
    //        public TestControlDesignerActionList(SimpPanelDesigner desinger) : base(desinger.Component)
    //        {
    //            m_Desinger = desinger;
    //        }

    //        public override DesignerActionItemCollection GetSortedActionItems()
    //        {
    //            DesignerActionItemCollection list = new DesignerActionItemCollection(); //base.GetSortedActionItems();
    //            list.Add(new DesignerActionMethodItem(this, "OnTest01ActionClick", "显示名01", "分类A", "描述0001"));
    //            list.Add(new DesignerActionMethodItem(this, "OnTest02ActionClick", "显示名02", "分类A", "描述0002"));
    //            list.Add(new DesignerActionMethodItem(this, "OnTest03ActionClick", "显示名03", "分类B", "描述0003"));
    //            return list;
    //        }

    //        public void OnTest01ActionClick() { m_Desinger.OnTest01ActionClick(); }
    //        public void OnTest02ActionClick() { m_Desinger.OnTest02ActionClick(); }
    //        public void OnTest03ActionClick() { m_Desinger.OnTest03ActionClick(); }
    //    }

    //    public override DesignerActionListCollection ActionLists
    //    {
    //        get
    //        {
    //            DesignerActionListCollection designerActionListCollection = new DesignerActionListCollection();
    //            TestControlDesignerActionList list = new TestControlDesignerActionList(this);
    //            designerActionListCollection.Add(list);
    //            return designerActionListCollection;
    //        }
    //    }


    //    private IDesignerHost designerHost;
    //    private SimpPanel simpPanel;
    //    //private Panel testControlPanel;
    //    //private bool testControlSelected;
    //    //private Panel selectedPanel;

    //    //private Panel Selected
    //    //{
    //    //    get
    //    //    {
    //    //        return this.selectedPanel;
    //    //    }
    //    //    set
    //    //    {
    //    //        selectedPanel = value;

    //    //        //if (this.selectedPanel != null)
    //    //        //{
    //    //        //    SplitterPanelDesigner splitterPanelDesigner = (SplitterPanelDesigner)this.designerHost.GetDesigner(this.selectedPanel);
    //    //        //    splitterPanelDesigner.Selected = false;
    //    //        //}
    //    //        //if (value != null)
    //    //        //{
    //    //        //    SplitterPanelDesigner splitterPanelDesigner2 = (SplitterPanelDesigner)this.designerHost.GetDesigner(value);
    //    //        //    this.selectedPanel = value;
    //    //        //    splitterPanelDesigner2.Selected = true;
    //    //        //    return;
    //    //        //}
    //    //        //if (this.selectedPanel != null)
    //    //        //{
    //    //        //    SplitterPanelDesigner splitterPanelDesigner3 = (SplitterPanelDesigner)this.designerHost.GetDesigner(this.selectedPanel);
    //    //        //    this.selectedPanel = null;
    //    //        //    splitterPanelDesigner3.Selected = false;
    //    //        //}
    //    //    }
    //    //}

    //    public override void Initialize(IComponent component)
    //    {
    //        base.Initialize(component);

    //        base.AutoResizeHandles = true;
    //        this.simpPanel = (SimpPanel)component;
    //        //this.testControlPanel = this.testControl.Panel;
    //        //base.EnableDesignMode(this.simpPanel.Panel, "Panel");
    //        this.designerHost = (IDesignerHost)component.Site.GetService(typeof(IDesignerHost));

    //        //ISelectionService selectionService = (ISelectionService)this.GetService(typeof(ISelectionService));
    //        //if (selectionService != null) selectionService.SelectionChanged += new EventHandler(this.OnSelectionChanged);
    //    }
    //    protected override bool AllowControlLasso
    //    {
    //        get
    //        {
    //            //return base.AllowControlLasso;
    //            return false;
    //        }
    //    }
    //    //protected override bool GetHitTest(Point point)
    //    //{
    //    //    return base.GetHitTest(point);
    //    //    return this.InheritanceAttribute != InheritanceAttribute.InheritedReadOnly && this.testControlSelected;
    //    //}
    //    //private void OnSelectionChanged(object sender, EventArgs e)
    //    //{
    //    //    ISelectionService selectionService = (ISelectionService)this.GetService(typeof(ISelectionService));
    //    //    this.testControlSelected = false;
    //    //    if (selectionService != null)
    //    //    {
    //    //        ICollection selectedComponents = selectionService.GetSelectedComponents();
    //    //        foreach (object current in selectedComponents)
    //    //        {
    //    //            Panel panel = CheckIfPanelSelected(current);
    //    //            if (panel != null && panel.Parent == this.testControl)
    //    //            {
    //    //                this.testControlSelected = false;
    //    //                this.Selected = panel;
    //    //                break;
    //    //            }
    //    //            this.Selected = null;
    //    //            if (current == this.testControl)
    //    //            {
    //    //                this.testControlSelected = true;
    //    //                break;
    //    //            }
    //    //        }
    //    //    }
    //    //}
    //    public override ControlDesigner InternalControlDesigner(int internalControlIndex)
    //    {
    //        //return base.InternalControlDesigner(internalControlIndex);

    //        //Panel component = null;
    //        //if (internalControlIndex == 0)
    //        //{
    //        //    component = this.selectedPanel;
    //        //}
    //        //else
    //        //{
    //        //    return null;
    //        //}
    //        //return this.designerHost.GetDesigner(component) as ControlDesigner;
    //        return null;
    //    }
    //    protected override IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize)
    //    {
    //        //ScrollableControlDesigner toInvoke = (ScrollableControlDesigner)this.designerHost.GetDesigner(this.testControlPanel);
    //        //ParentControlDesigner.InvokeCreateTool(toInvoke, tool);
    //        return null;
    //    }

    //    private static Panel CheckIfPanelSelected(object comp)
    //    {
    //        return comp as Panel;
    //    }




    //    public void OnTest01ActionClick()
    //    {
    //        MessageBox.Show("OnTest01ActionClick()");

    //        //PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(testControlPanel)["BackColor"];
    //        //propertyDescriptor.SetValue(testControlPanel, Color.Black);

    //        //DesignerActionUIService designerActionUIService = (DesignerActionUIService)this.GetService(typeof(DesignerActionUIService));
    //        //if (designerActionUIService != null) designerActionUIService.Refresh(testControl);
    //    }
    //    public void OnTest02ActionClick()
    //    {
    //        MessageBox.Show("OnTest02ActionClick()");

    //        //PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(testControlPanel)["BackColor"];
    //        //propertyDescriptor.SetValue(testControlPanel, SystemColors.Control);

    //        //DesignerActionUIService designerActionUIService = (DesignerActionUIService)this.GetService(typeof(DesignerActionUIService));
    //        //if (designerActionUIService != null) designerActionUIService.Refresh(testControl);
    //    }
    //    public void OnTest03ActionClick()
    //    {
    //        MessageBox.Show("OnTest03ActionClick()");
    //    }

    //}


}
